package com.mytest.example.gobrs.component;

import com.gobrs.async.callback.AsyncTaskExceptionInterceptor;
import com.gobrs.async.callback.ErrorCallback;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;


@Slf4j
@Component
public class GobrsExceptionInter implements AsyncTaskExceptionInterceptor {

    @Override
    public void exception(ErrorCallback errorCallback) {
        log.error("自定义全局异常 exceptor Interceptor 触发");
        log.error("异常信息:" + errorCallback.getThrowable().toString());
        //超时异常
        if (errorCallback.getThrowable() instanceof com.gobrs.async.exception.TimeoutException) {
            errorCallback.getTask().stopAsync(errorCallback.getSupport(), 504);
        }
    }
}